package com.junxonline.instant.dao.entity.model.config;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.junxonline.instant.common.entity.common.CommonEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 系统用户表实体类
 *
 * @author JunX
 * @date 2021-06-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "sys_user")
public class User extends CommonEntity {

    /**
     * ID
     */
    @TableId(type = IdType.INPUT)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

    /**
     * 用户名
     */
    @TableField(value = "username")
    private String username;

    /**
     * 密码
     */
    @JsonIgnore
    @TableField(value = "password")
    private String password;

    /**
     * 昵称
     */
    @TableField(value = "nickname")
    private String nickname;

    /**
     * 性别
     */
    @TableField(value = "gender")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer gender;

    /**
     * 联系电话
     */
    @TableField(value = "phone")
    private String phone;

    /**
     * 电子邮箱
     */
    @TableField(value = "email")
    private String email;

    /**
     * 头像
     */
    @TableField(value = "avatar")
    private String avatar;

    /**
     * 状态
     */
    @TableField(value = "status")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer status;

    /**
     * 组织机构ID
     */
    @TableField(value = "organization_id")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long organizationId;

    /**
     * 是否逻辑删除
     */
    @TableField(value = "del")
    @TableLogic
    private Integer del;

    /**
     * 所属机构
     */
    @TableField(exist = false)
    private String organizationName;

    /**
     * 拥有角色名称
     */
    @TableField(exist = false)
    private String roleNames;

    /**
     * 拥有角色ID
     */
    @TableField(exist = false)
    private List<String> roles;

}
